<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('项目角色管理')" />
    <th:block th:include="include :: layout-latest-css" />
    <th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>角色名称：</label>
                                <input type="text" name="name"/>
                            </li>
                            <li>
                                <label>角色编码：</label>
                                <input type="text" name="code"/>
                            </li>
                            <li>
                                <label>状态：</label>
                                <select name="status" id="status">
                                    <option value="">所有</option>
                                    <option value="0">正常</option>
                                    <option value="1">停用</option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="pm:project:role:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-danger" onclick="$.operate.removeAll()" shiro:hasPermission="pm:project:role:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: layout-latest-js" />
    <th:block th:include="include :: bootstrap-select-js" />
    <script th:inline="javascript">
        var detailFlag = [[${@permission.hasPermi('pm:project:role:detail')}]];
        var listFlag = [[${@permission.hasPermi('pm:project:role:list')}]];
        var editFlag = [[${@permission.hasPermi('pm:project:role:edit')}]];
        var removeFlag = [[${@permission.hasPermi('pm:project:role:remove')}]];
        var prefix = ctx + "project/role";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                modalName: "项目角色",
                columns: [{
                    checkbox: true,
                    visible: removeFlag != 'hidden'
                },
                {
                    field: 'id',
                    title: '主键ID',
                    visible: false
                },
                {
                    field: 'name',
                    title: '角色名称'
                },
                {
                    field: 'code',
                    title: '角色编码'
                },
                {
                    field: 'sortOrder',
                    title: '排序号',
                    align: 'center'
                },
                {
                    field: 'status',
                    title: '状态',
                    align: 'center',
                    formatter: function(value, row, index) {
                        if (value == '0') {
                            return '<span class="label label-success">正常</span>';
                        } else {
                            return '<span class="label label-danger">停用</span>';
                        }
                    }
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    formatter: function(value, row, index) {
                        return $.common.dateFormat(value);
                    }
                },
                {
                    field: 'remark',
                    title: '备注'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-warning btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.id + '\')"><i class="fa fa-search"></i> 详细</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i> 编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i> 删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>